package com.gitee.lougnib.hellowebim.common.mybatis.mapper;

import static com.gitee.lougnib.hellowebim.common.mybatis.mapper.ChatRoomUserEntityDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.gitee.lougnib.hellowebim.common.mybatis.entity.ChatRoomUserEntity;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface ChatRoomUserMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    BasicColumn[] selectList = BasicColumn.columnList(id, chatRoomId, remark, userId, visitorId, lastAccessTime, accessCount, lastAccessFailTime, lastAccessFailCount, accessLevel, userAgent, version);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<ChatRoomUserEntity> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<ChatRoomUserEntity> multipleInsertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("ChatRoomUserEntityResult")
    Optional<ChatRoomUserEntity> selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="ChatRoomUserEntityResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="chat_room_id", property="chatRoomId", jdbcType=JdbcType.BIGINT),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="visitor_id", property="visitorId", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_access_time", property="lastAccessTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="access_count", property="accessCount", jdbcType=JdbcType.INTEGER),
        @Result(column="last_access_fail_time", property="lastAccessFailTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_access_fail_count", property="lastAccessFailCount", jdbcType=JdbcType.INTEGER),
        @Result(column="access_level", property="accessLevel", jdbcType=JdbcType.INTEGER),
        @Result(column="user_agent", property="userAgent", jdbcType=JdbcType.VARCHAR),
        @Result(column="version", property="version", jdbcType=JdbcType.INTEGER)
    })
    List<ChatRoomUserEntity> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, chatRoomUserEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, chatRoomUserEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(ChatRoomUserEntity record) {
        return MyBatis3Utils.insert(this::insert, record, chatRoomUserEntity, c ->
            c.map(id).toProperty("id")
            .map(chatRoomId).toProperty("chatRoomId")
            .map(remark).toProperty("remark")
            .map(userId).toProperty("userId")
            .map(visitorId).toProperty("visitorId")
            .map(lastAccessTime).toProperty("lastAccessTime")
            .map(accessCount).toProperty("accessCount")
            .map(lastAccessFailTime).toProperty("lastAccessFailTime")
            .map(lastAccessFailCount).toProperty("lastAccessFailCount")
            .map(accessLevel).toProperty("accessLevel")
            .map(userAgent).toProperty("userAgent")
            .map(version).toProperty("version")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertMultiple(Collection<ChatRoomUserEntity> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, chatRoomUserEntity, c ->
            c.map(id).toProperty("id")
            .map(chatRoomId).toProperty("chatRoomId")
            .map(remark).toProperty("remark")
            .map(userId).toProperty("userId")
            .map(visitorId).toProperty("visitorId")
            .map(lastAccessTime).toProperty("lastAccessTime")
            .map(accessCount).toProperty("accessCount")
            .map(lastAccessFailTime).toProperty("lastAccessFailTime")
            .map(lastAccessFailCount).toProperty("lastAccessFailCount")
            .map(accessLevel).toProperty("accessLevel")
            .map(userAgent).toProperty("userAgent")
            .map(version).toProperty("version")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(ChatRoomUserEntity record) {
        return MyBatis3Utils.insert(this::insert, record, chatRoomUserEntity, c ->
            c.map(id).toPropertyWhenPresent("id", record::getId)
            .map(chatRoomId).toPropertyWhenPresent("chatRoomId", record::getChatRoomId)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
            .map(userId).toPropertyWhenPresent("userId", record::getUserId)
            .map(visitorId).toPropertyWhenPresent("visitorId", record::getVisitorId)
            .map(lastAccessTime).toPropertyWhenPresent("lastAccessTime", record::getLastAccessTime)
            .map(accessCount).toPropertyWhenPresent("accessCount", record::getAccessCount)
            .map(lastAccessFailTime).toPropertyWhenPresent("lastAccessFailTime", record::getLastAccessFailTime)
            .map(lastAccessFailCount).toPropertyWhenPresent("lastAccessFailCount", record::getLastAccessFailCount)
            .map(accessLevel).toPropertyWhenPresent("accessLevel", record::getAccessLevel)
            .map(userAgent).toPropertyWhenPresent("userAgent", record::getUserAgent)
            .map(version).toPropertyWhenPresent("version", record::getVersion)
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<ChatRoomUserEntity> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, chatRoomUserEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<ChatRoomUserEntity> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, chatRoomUserEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<ChatRoomUserEntity> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, chatRoomUserEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<ChatRoomUserEntity> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, chatRoomUserEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateAllColumns(ChatRoomUserEntity record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(record::getId)
                .set(chatRoomId).equalTo(record::getChatRoomId)
                .set(remark).equalTo(record::getRemark)
                .set(userId).equalTo(record::getUserId)
                .set(visitorId).equalTo(record::getVisitorId)
                .set(lastAccessTime).equalTo(record::getLastAccessTime)
                .set(accessCount).equalTo(record::getAccessCount)
                .set(lastAccessFailTime).equalTo(record::getLastAccessFailTime)
                .set(lastAccessFailCount).equalTo(record::getLastAccessFailCount)
                .set(accessLevel).equalTo(record::getAccessLevel)
                .set(userAgent).equalTo(record::getUserAgent)
                .set(version).equalTo(record::getVersion);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(ChatRoomUserEntity record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(record::getId)
                .set(chatRoomId).equalToWhenPresent(record::getChatRoomId)
                .set(remark).equalToWhenPresent(record::getRemark)
                .set(userId).equalToWhenPresent(record::getUserId)
                .set(visitorId).equalToWhenPresent(record::getVisitorId)
                .set(lastAccessTime).equalToWhenPresent(record::getLastAccessTime)
                .set(accessCount).equalToWhenPresent(record::getAccessCount)
                .set(lastAccessFailTime).equalToWhenPresent(record::getLastAccessFailTime)
                .set(lastAccessFailCount).equalToWhenPresent(record::getLastAccessFailCount)
                .set(accessLevel).equalToWhenPresent(record::getAccessLevel)
                .set(userAgent).equalToWhenPresent(record::getUserAgent)
                .set(version).equalToWhenPresent(record::getVersion);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(ChatRoomUserEntity record) {
        return update(c ->
            c.set(chatRoomId).equalTo(record::getChatRoomId)
            .set(remark).equalTo(record::getRemark)
            .set(userId).equalTo(record::getUserId)
            .set(visitorId).equalTo(record::getVisitorId)
            .set(lastAccessTime).equalTo(record::getLastAccessTime)
            .set(accessCount).equalTo(record::getAccessCount)
            .set(lastAccessFailTime).equalTo(record::getLastAccessFailTime)
            .set(lastAccessFailCount).equalTo(record::getLastAccessFailCount)
            .set(accessLevel).equalTo(record::getAccessLevel)
            .set(userAgent).equalTo(record::getUserAgent)
            .set(version).equalTo(record::getVersion)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(ChatRoomUserEntity record) {
        return update(c ->
            c.set(chatRoomId).equalToWhenPresent(record::getChatRoomId)
            .set(remark).equalToWhenPresent(record::getRemark)
            .set(userId).equalToWhenPresent(record::getUserId)
            .set(visitorId).equalToWhenPresent(record::getVisitorId)
            .set(lastAccessTime).equalToWhenPresent(record::getLastAccessTime)
            .set(accessCount).equalToWhenPresent(record::getAccessCount)
            .set(lastAccessFailTime).equalToWhenPresent(record::getLastAccessFailTime)
            .set(lastAccessFailCount).equalToWhenPresent(record::getLastAccessFailCount)
            .set(accessLevel).equalToWhenPresent(record::getAccessLevel)
            .set(userAgent).equalToWhenPresent(record::getUserAgent)
            .set(version).equalToWhenPresent(record::getVersion)
            .where(id, isEqualTo(record::getId))
        );
    }
}